﻿// -------------------------------------------------------------------------
//    @FileName         :    NFTitlePart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFTitlePart
//
// -------------------------------------------------------------------------

#include "NFTitlePart.h"

#include "NFTitleUtil.h"
#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"
#include "DescStore/TitleDesc.h"

NFTitlePart::NFTitlePart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFTitlePart::~NFTitlePart()
{
}

int NFTitlePart::CreateInit()
{
    return 0;
}
    
int NFTitlePart::ResumeInit()
{
    return 0;
}

int NFTitlePart::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().title_data());
    return 0;
}

int NFTitlePart::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne &stRoleOne)
{
    CHECK_NULL(0, pDbData);
    pDbData->mutable_role_play_data()->mutable_title_data();
    return 0;
}

int NFTitlePart::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_title_data());
    return 0;
}

int NFTitlePart::SaveRoleSimpleInfo(proto_ff::Proto_RoleSimpleInfo* pDbData)
{
    CHECK_NULL(0, pDbData);
    pDbData->set_title_id(m_stData.active_title_id);
    pDbData->set_title_item_id(m_stData.title_item.id);
    return 0;
}

int NFTitlePart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_title_data());
    return 0;
}

int NFTitlePart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    pGCCityRoleInfo->set_title_item_id(m_stData.title_item.id);
    pGCCityRoleInfo->set_title_name(NFTitleUtil::GetTitleName(GetPlayer(), m_stData.active_title_id));
    return 0;
}

